import {reqGetSearchInfo} from '@/api';
const state ={
      searchlist:{},
    
};
//mutations :修改state的唯一手段
const mutations ={
      CATESEARCHLIST(state,searchlist){
            state.searchlist = searchlist;
      }  
};
//actions:处理action,可以书写自己的业务逻辑,也可以处理异步
const actions ={
      async getSearchList({commit},params={}){
        let result = await reqGetSearchInfo(params);
        if(result.code === 200){
              commit('CATESEARCHLIST',result.data);
        }
      }
};
//getters:理解为计算属性,用于简化仓库数据,让组件获取仓库的数据更加方便
const getters ={
      attrsList(state){
            return state.searchlist.attrsList || [];
      },
      goodsList(state){
            return state.searchlist.goodsList || [];  
      },
      trademarkList(state){
            return state.searchlist.trademarkList || [];  
      }
};

//对外暴露store类的一个实例
export default {
      state,
      mutations,
      actions,
      getters
}